#define _CRT_SECURE_NO_WARNINGS 1
#include"expression.h"
void init(ex* p)
{
	p->arr = (c*)malloc(sizeof(c) * 10);
	assert(p->arr);
	p->size = 0;
}
void find(ex* p, c* str)
{
	while (*str != '\0')
	{
		if (*str >= '0' && *str <= '9')
		{
			p->arr[p->size] = *str;
			p->size++;
			str++;
		}
		else
		{
			if (*str == '*')
			{
				char t = ((p->arr[(p->size) - 2] - '0') * (p->arr[(p->size) - 1] - '0') + '0');
				(p->size) -= 2;
				p->arr[p->size] = t;
				p->size++;
				str++;
			}
			else if (*str == '+')
			{
				char t = ((p->arr[(p->size) - 2] - '0') + (p->arr[(p->size) - 1] - '0') + '0');
				p->size-=2;
				p->arr[p->size] = t;
				p->size++;
				str++;
			}
			else if (*str == '-')
			{
				char t = ((p->arr[(p->size) - 2] - '0') - (p->arr[(p->size) - 1] - '0') + '0');
				p->size -= 2;
				p->arr[p->size] = t;
				p->size++;
				str++;
			}
			else
			{
				char t = ((p->arr[(p->size) - 2] - '0') / (p->arr[(p->size) - 1] - '0') + '0');
				p->size-=2;
				p->arr[p->size] = t;
				p->size++;
				str++;
			}
		}
	}
	printf("%c", p->arr[p->size - 1]);
}
